﻿<?php


  $sql = "select *from `roles`";
  $rel = mysqli_query($link,$sql);
  while ($d = mysqli_fetch_assoc($rel)){
        $data[] = $d;
  }

if(!empty($data)){
 foreach ($data as $k => $v) {
   $arr=array();
   $sql="select `name` from `power` where `id` in ($v[power])";
   $rel = mysqli_query($link,$sql);

   while ($d = mysqli_fetch_assoc($rel)){
        $arr[]= $d;
  }
   $data[$k]['ch']=$arr;

 }
}

  // $sqla = "select `power` from `roles`";
  // $rela = mysqli_query($link,$sqla);
  // while ($da = mysqli_fetch_assoc($rela)){
  //       $dataa[] = $da;
  // }


  // foreach($dataa as $k=>$v){
  //       $id[] = implode(',',$v);

  // }
  // foreach($id as $ke=>$va){
  //   $sqlb = "select `id`,`name` from `power` where `id` in ($va)";
  //   $relb = mysqli_query($link,$sqlb);
  //   while ($db = mysqli_fetch_assoc($relb)){
  //       $datab[] = $db;
  // }

  // }

  //print_r($id);
  //print_r($dataa);die;
//print_r($data);die;
		include(CON_VIEW.$q.'/common.html');
?>